package com.xt.yncu.common.util;

import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class XmlParse {
	public static boolean isXml(String xml){
		if (xml.indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")!=0
				&& xml.indexOf("<?xml version=\"1.0\" encoding=\"utf-8\"?>")!=0) {
			return false;
		}
		return true;
	}
	@SuppressWarnings("unchecked")
	public static boolean isException(String xml){
		try {
			Document document=DocumentHelper.parseText(xml);
			Element root=document.getRootElement();
			List<Object> exception=root.elements("exception");//.selectNodes("exception");
			if (exception!=null && !exception.isEmpty()) {
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}
